import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    user: {},
  },
  getters:{
    user: (state) => state.user
  },
  mutations: {
    Login(state, user) {
      console.log(user);
      state.user = user;
      localStorage.setItem("user", JSON.stringify(user));
    },
    Logout(state) {
      state.user = {};
      localStorage.removeItem("user");
    },
  },
  actions: {
    setLogin({ commit }, user){
      commit('Login', user)
    },
    setLogout({ commit }){
      commit('Logout')
    }
  },
  modules: {},
});
